package com.lyh.db137.controller;

import com.lyh.db137.common.R;
import com.lyh.db137.entity.Role;
import com.lyh.db137.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: 想要告诉你
 * @CreateTime: 2024/12/31 10:45
 * @Description:
 * @Version: 1.0
 */

@RestController
@CrossOrigin(origins = "*")
public class RoleController {
    @Autowired
    private RoleService roleService;

    //查询所有
    @RequestMapping("/selectAllRole")
    public R selectAllRole() {
        List<Role> roles = roleService.list();
        return new R().addData("roles", roles);
    }

    //查询单个
    @RequestMapping("/selectRoleById")
    public R selectRoleById(Integer id) {
        Role roles = roleService.getById(id);
        return new R().addData("roles", roles);
    }
}
